import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'package:getx_demo_2/main/view.dart';
import 'package:getx_demo_2/resource/string.dart';
import 'package:getx_demo_2/route/route.dart';
import 'dart:ui' as ui;

import 'package:getx_demo_2/service/init_service.dart';

void main() {
  Global.init(() {
    runApp(GetMaterialApp(
      home: ScreenUtilInit(
        builder: () => MainPage(),
        designSize: const Size(375, 812),
      ),
      initialRoute: RouteGet.main,
      getPages: RouteGet.getPages,
      translations: Strings(),
      locale: ui.window.locale,
      fallbackLocale: const Locale('en', 'US'),
      defaultTransition:
          GetPlatform.isIOS ? Transition.native : Transition.cupertino, // 转场动画
    ));
  });
}

class Global {
  static Future init(VoidCallback callback) async {
    callback();
    await Get.putAsync(() => InitService().init());
  }
}
